package com.voxel.sense.infomsg.module.trace.staff;

import android.content.Context;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.com.common.view.recycler.RecyclerAdapter;
import com.voxel.sense.infomsg.R;
import cyy.example.com.facotry.model.api.response.ClockInUserListEntity;
import com.voxel.sense.infomsg.utils.GlideUtils;

import butterknife.BindView;

/**
 * Created by ChenYiYao on 2018/5/21.
 */
public class StaffListAdapter extends RecyclerAdapter<ClockInUserListEntity.BodyBean> {


    @Override
    protected int getItemViewType(int position, ClockInUserListEntity.BodyBean bodyBean) {
        return R.layout.item_recycler_staff_list;
    }

    @Override
    protected ViewHolder onCreateViewHolder(View root, int viewType) {
        return new ViewHolder(root);
    }

    public static class ViewHolder extends RecyclerAdapter.ViewHolder<ClockInUserListEntity.BodyBean> {

        @BindView(R.id.tv_name)
        TextView tv_name;
        @BindView(R.id.tv_status)
        TextView tv_status;
        @BindView(R.id.iv_portrait)
        ImageView iv_portrait;

        public ViewHolder(View itemView) {
            super(itemView);
        }

        @Override
        protected void onBind(ClockInUserListEntity.BodyBean bodyBean) {
            tv_name.setText(bodyBean.getUserName() + "(id:" + bodyBean.getUserId() + ")");
            tv_status.setText(bodyBean.getUserRole());
            Context context = iv_portrait.getContext();
            GlideUtils.GlideLoadPortrait(context, bodyBean.getHeadImg(), iv_portrait);
        }
    }
}
